<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path %>/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="<%=path %>/js/moment.js"></script>
    <script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
    <script type="text/javascript">
        function deletes(id) {
            window.location.href = "<%=basePath%>deleteDrugs?drugsid=" + id;
        }

        function modify(id) {
            window.location.href = "<%=basePath%>getDrugsId?drugsid=" + id;
        }

        function cz(id) {
            window.location.href = "<%=basePath%>getDrugsId1?drugsid=" + id;
        }

        function upload(id) {
            window.location.href = "<%=path%>/html/ypupload.jsp?drugsId=" + id;
        }

        function downloadFile(id) {
            window.location.href = "<%=basePath%>download?drugsId=" + id;
        }

        function chgPageSize(size) {
            document.forms[0].action = "<%=basePath%>showSomeDrugs?pageNo=1&pageSize=" + size;
            document.forms[0].submit();
            return false;
        }

        function goPage(pageNo) {
            if (pageNo < 1) {
                return false;
            }
            if (pageNo >${drugses.pageCount}) {
                return false;
            }
            document.forms[0].action = "<%=basePath%>showSomeDrugs?pageSize=${drugses.pageSize}&pageNo=" + pageNo;
            document.forms[0].submit();
            return false;
        }

        $(function () {
            $('tbody tr:odd').addClass("trLight");

            $(".select-all").click(function () {
                if ($(this).attr("checked")) {
                    $(".checkBox input[type=checkbox]").each(function () {
                        $(this).attr("checked", true);
                    });
                } else {
                    $(".checkBox input[type=checkbox]").each(function () {
                        $(this).attr("checked", false);
                    });
                }
            });

        });
    </script>
    <style type="text/css">
        body {
            background: #FFF
        }
    </style>
</head>

<body>
<div id="contentWrap">
    <!--表格控件 -->
    <div id="widget table-widget">
        <div class="pageTitle">药品管理</div>
        <div class="querybody">
            <form action="<%=basePath%>showSomeDrugs" method="post">
                <ul class="seachform">
                    <li><label>药品ID</label><input name="drugsId" type="text" class="scinput"/></li>
                    <li><label>药品名称</label><input name="name" type="text" class="scinput"/></li>
                    <li><label>&nbsp;</label><input name="" type="submit" class="scbtn" value="查询"/></li>
                </ul>
            </form>
        </div>
        <div class="pageColumn">
            <div class="pageButton"><a href="<%=path%>/html/ypadd.jsp"><img src="<%=path %>/images/t01.png" title="新增"/></a><span>药品列表</span>
            </div>
            <table>
                <thead>
                <th width="">药品ID</th>
                <th width="">药品名称</th>
                <th width="">进价</th>
                <th width="">售价</th>
                <th width="">库存数量</th>
                <th width="">引入日期</th>
                <th width="">生产厂商</th>
                <th width="">生产日期</th>
                <th width="">保质期</th>
                <th width="">供货单位</th>
                <th width="10%">操作</th>
                <th width="10%">库存新增</th>
                </thead>
                <tbody>
                <c:forEach items="${drugses.list}" var="drugs" varStatus="s">
                    <tr>
                        <td>${drugs.drugsId}</td>
                        <td>${drugs.name}</td>
                        <td>${drugs.purchasePrice}</td>
                        <td>${drugs.price}</td>
                        <td><font color="red">${drugs.num}</font></td>
                        <td><span id="introduceDate"><fmt:formatDate value="${drugs.introduceDate}"
                                                                     pattern="yyyy-MM-dd"/></span></td>
                        <td>${drugs.productUnit}</td>
                        <td><span id="productDate"><fmt:formatDate value="${drugs.productDate}"
                                                                   pattern="yyyy-MM-dd"/></span></td>
                        <td>${drugs.qualityPeriod}</td>
                        <td>${drugs.supplyUnit}</td>
                        <td>
                            <a onclick="modify(${drugs.drugsId})"><img src="<%=path %>/images/icon/edit.png" width="16"
                                                                       height="16"/></a>
                            <a onclick="deletes(${drugs.drugsId})"><img src="<%=path %>/images/icon/del.png" width="16"
                                                                        height="16"/></a>
                            <a onclick="upload('${drugs.drugsId}')"><img src="<%=path %>/images/icon/setup.png"
                                                                         width="16"
                                                                         height="16"/></a>
                            <c:if test="${drugs.realFilename!=null}">
                                <a onclick="downloadFile('${drugs.drugsId}')"><img src="<%=path %>/images/icon/save.png"
                                                                                   width="16" height="16"/></a>
                            </c:if>
                        </td>
                        <td>
                            <a onclick="cz(${drugs.drugsId})"><img src="<%=path %>/images/icon/edit2.png" width="16"
                                                                   height="16"/></a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <div id="pagination" style="align:right;margin-top:-10px;">
        <div id='project_pagination' class="pagination pagination-centered">
            <div class="pagination">
                <ul>
                    <li ><a href="javascript:goPage(${drugses.pageNo-1})">«</a></li>
                    <c:forEach begin="${drugses.pageNo-2<1?1:drugses.pageNo-2}" end="${drugses.pageNo+2}" var="cnt">
                        <c:if test="${cnt>=1 and cnt<=drugses.pageCount}">
                            <li class="${cnt==drugses.pageNo?'active':''}"><a href="javascript:goPage(${cnt})">${cnt}</a></li>
                        </c:if>
                    </c:forEach>


                    <li><a href="javascript:goPage(${drugses.pageNo+1})">»</a></li>
                </ul>
                <ul>
                    <li><span>(${drugses.firstResult+1}-${drugses.firstResult+drugses.pageSize>drugses.rowCount?drugses.rowCount:drugses.firstResult+drugses.pageSize}/${drugses.rowCount})</span></li>
                    <li><span>显示条数&nbsp;:&nbsp;</span></li>
                </ul>
                <ul>
                    <li class="${drugses.pageSize==2?'active':''}"><a href="javascript:chgPageSize(2)">2</a></li>
                    <li class="${drugses.pageSize==30?'active':''}"><a href="javascript:chgPageSize(30)">30</a></li>
                    <li class="${drugses.pageSize==50?'active':''}"><a href="javascript:chgPageSize(50)">50</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>

